<template>
	<view class="content">
		<view class="form">
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					学生姓名
				</view>
				<view class="ipt">
					{{info.username}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					手机号码
				</view>
				<view class="ipt">
					{{info.phone}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					邮箱
				</view>
				<view class="ipt">
					{{info.mailbox}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					学校名称
				</view>
				<view class="ipt" @tap="schoolShow = true">
					{{schoolText}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					性别
				</view>
				<view class="ipt" @tap="sexShow = true">
					{{sexText}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					年龄
				</view>
				<view class="ipt">
					{{info.age}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					年级
				</view>
				<view class="ipt">
					{{info.grade}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					家长手机号
				</view>
				<view class="ipt">
					{{info.parents_phone}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					渠道
				</view>
				<view class="ipt" @tap="fromShow = true">
					{{fromText}}
				</view>
			</view>
			<view class="item">
				<view class="label">
					<view class="starImg"></view>
					学生情况
				</view>
				<view class="ipt">
					{{info.student_situation}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				schoolText: "",
				sexText: "",
				fromText: "",
				info: {
					user_id: '',
					username: '',
					phone: '',
					mailbox: '',
					school_id: '',
					sex: 3,
					age: '',
					grade: '',
					parents_phone: '',
					from: '',
					student_situation: ''
				}
			};
		},
		onLoad(option) {
			this.info.user_id = option.user_id
			this.getData(option.user_id)
			this.getAllSchool();
		},
		methods: {
			async getData(user_id) {
				const {
					data: res
				} = await uni.$http.post('school/student/getUserDetail', {
					user_id: user_id
				})
				if (res.code != 1) {
					return this.toast.msg(res.msg)
				}
				this.info = res.data;

				if (res.data.sex == 1) {
					this.sexText = '男'
				}
				if (res.data.sex == 2) {
					this.sexText = '女'
				}
				if (res.data.sex == 3) {
					this.sexText = '未知'
				}
				
				if (res.data.from == 1) {
					this.fromText = '个人'
				}
				if (res.data.from == 2) {
					this.fromText = '电销'
				}
				if (res.data.from == 3) {
					this.fromText = '抖音'
				}
				if (res.data.from == 4) {
					this.fromText = '地摊'
				}
				if (res.data.from == 5) {
					this.fromText = '合作'
				}
				if (res.data.from == 6) {
					this.fromText = '介绍'
				}
			},
			async getAllSchool() {
				const {
					data: res
				} = await uni.$http.post('school/index/getAllSchool')
				if (res.code != 1) {
					return this.toast.msg(res.msg)
				}
				res.data.forEach(i=>{
					if(this.info.school_id == i.id) {
						this.schoolText = i.school_name
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		min-height: 100vh;

		.form {
			width: 652rpx;
			margin: 40rpx auto;

			.item {
				display: flex;
				align-items: center;
				padding: 0 35rpx 0 19rpx;
				margin-bottom: 30rpx;
				width: 652rpx;
				height: 78rpx;
				line-height: 78rpx;
				border-radius: 10rpx;
				border: 2rpx solid #FCF7F7;

				.label {
					display: flex;
					align-items: center;
					font-size: 28rpx;
					margin-right: 70rpx;
					width: 160rpx;

					.starImg {
						width: 14rpx;
						height: 42rpx;
						margin-right: 15rpx;
					}
				}

				.ipt {
					flex: 1;
					position: relative;
					display: flex;
					align-items: center;
					color: #666;

					.lowerImg {
						position: absolute;
						right: 0;
						width: 20rpx;
						height: 11rpx;
					}
				}

				.time {
					color: #666;
					display: flex;
					align-items: center;

					.timeImg {
						width: 35rpx;
						height: 35rpx;
						margin-right: 17rpx;

					}
				}
			}

			.textBox {
				padding: 0 35rpx 0 19rpx;
				display: flex;
				border: 2rpx solid #FCF7F7;

				.label {
					height: 70rpx;
					display: flex;
					align-items: center;
					font-size: 28rpx;
					margin-right: 70rpx;
					width: 160rpx;

					.starImg {
						width: 14rpx;
						height: 42rpx;
						margin-right: 15rpx;
					}
				}

				.ipt {
					flex: 1;
					height: 352rpx;

					.u-textarea {
						height: 352rpx;
						border: none;
						padding-left: 0;

						/deep/.u-textarea__field {
							height: 352rpx !important;
						}

						.uni-textarea-textarea {
							height: 352rpx;
						}
					}
				}
			}
		}

		.btn {
			position: fixed;
			bottom: 50rpx;
			left: 50%;
			transform: translateX(-50%);
			width: 652rpx;
			height: 78rpx;
			line-height: 78rpx;
			text-align: center;
			background: #CCCCCC;
			border: 2rpx solid #69A1E0;
		}
	}
</style>